package mutation;

import java.util.*;

import GA.*;
import Operations.Operation;
import Operations.ValuesGenerator;
import util.*;


public class InsertRandomMethodCall extends MutationStrategy {

	@Override
	public Chromosome mutate( Chromosome individual) {
		List<Operation> ops= individual.getTest();
		try {
			int randPos = ValuesGenerator.getRandomInt(ops.size());
			List<Operation>  rep= new LinkedList<Operation>();
			rep.addAll(ops.subList(0, randPos));
			rep.add( Operation.randomlyGenerate(TestCluster));
			rep.addAll(ops.subList(randPos, ops.size()));
			individual.setTest(rep);
			return individual;
		} catch (Throwable e){
			System.err.println("Insert Random Method Call Class:" + e.getMessage());
		}	

		
		return null;
		
	}

	@Override
	public boolean getMutationFlag() {
		return true;
	}
}
